#import "AppDelegate.h"
#import "GeneratedPluginRegistrant.h"
//#include "FlutterDownloaderPlugin.h"
@implementation AppDelegate

// void registerPlugins(NSObject<FlutterPluginRegistry>* registry) {
//   if (![registry hasPlugin:@"FlutterDownloaderPlugin"]) {
//      [FlutterDownloaderPlugin registerWithRegistrar:[registry registrarForPlugin:@"FlutterDownloaderPlugin"]];
//   }
// }
- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [GeneratedPluginRegistrant registerWithRegistry:self];
   // 初始化 Flutter 根视图控制器
    FlutterViewController *controller = (FlutterViewController *)self.window.rootViewController;

    // 设置 Method Channel
    FlutterMethodChannel *languageChannel = [FlutterMethodChannel
                                             methodChannelWithName:@"com.amos.get/language"
                                             binaryMessenger:controller.binaryMessenger];

    // 注册方法处理器
    [languageChannel setMethodCallHandler:^(FlutterMethodCall *call, FlutterResult result) {
        if ([call.method isEqualToString:@"getLanguage"]) {
            // 获取系统语言
            NSString *preferredLanguage = [[NSLocale preferredLanguages] firstObject];
            result(preferredLanguage);
        } else {
            result(FlutterMethodNotImplemented);
        }
    }];

    // 注册 Flutter 插件
  // [GeneratedPluginRegistrant registerWithRegistry:self];
  // [FlutterDownloaderPlugin setPluginRegistrantCallback:registerPlugins];
  // Override point for customization after application launch.
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@end
